var express = require('express');
var axios = require('axios');
var router = express.Router();

router.get('/',(req, res, next) => {
    if (req.session.login) {
        next()
    } else {
        res.send({ err: -999, msg: '请先登录' })
    }
}, function (req, res, next) {
    var config = {
        method: 'post',
        baseURL: 'http://localhost:9023',
        url: '/exam/getExamByStatus',
        params: {
            status: '0'
        },
    }
    axios(config)
        .then(function (response) {
            console.log(response.data);
            if (response.data.code == 0) {
                console.log("获取信息成功")
                res.render('admin/goExam', {
                    list: response.data.data
                });
            } else {
                // console.log(response);
                res.send({ err: -1, msg: "获取信息失败" })
                console.log("获取信息失败")
            }
        })
        .catch(function (error) {
            console.log(error);
            res.send({ err: -1, msg: "服务器错误" })
            console.log("服务器错误")
        });
})


module.exports = router;
